﻿using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
namespace ScormModel
{
    [Serializable()]
    public class Metadata
    {
        private string _schema = "";
        private string _schemaVersion = "";
        private string _location;
        [NonSerialized]
        private XmlNode _metadataContent;

        [XmlIgnoreAttribute]
        public XmlNode MetadataContent
        {
            get { return this._metadataContent; }
            set { this._metadataContent = value; }
        }
        [XmlElement("schema")]
        public string Schema
        {
            get { return this._schema; }
            set { this._schema = value; }
        }

        [XmlElement("schemaversion")]
        public string SchemaVersion
        {
            get { return this._schemaVersion; }
            set { this._schemaVersion = value; }
        }

        [XmlElement("location",Namespace= "http://www.adlnet.org/xsd/adlcp_v1p3")]
        public string Location
        {
            get { return this._location; }
            set { this._location = value; }
        }
        
        public void buildMetadata()
        {
            //incomplete
            XmlNodeList childList = _metadataContent.ChildNodes;
            for (int i = 0; i < childList.Count; i++)
            {
                if (childList[i].Name == "schema")
                {
                    _schema = childList[i].InnerText;
                }
                else if (childList[i].Name == "schemaversion")
                {
                    _schemaVersion = childList[i].InnerText;
                }
                else if (childList[i].Name == "location")
                {
                    _location = childList[i].InnerText;
                }
            }
        }

    }
}
